<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<jsp:include page="../jqgrid.jsp"></jsp:include>
</head>
<script type="text/javascript">
	var equipmentId = "";
	$(document).ready(function() {
		jQuery("#employeelist").jqGrid({
			url : 'queryEmployee.action',
			autowidth : true,
			datatype : "json",
			colNames : [ 'id', '姓名', '性别', '家庭住址', '电话', '年龄', '状态', '入职时间 '],
			colModel : [ {
				name : 'id',
				index : 'id',
				width : 20,
				editable : false,
				hidden:true,
				searchoptions :{
					sopt:['cn','nc']
				}
			}, {
				name : 'name',
				index : 'name',
				width : 50,
				editable : true,
				align : "center",
				editrules:{
					required:true
				},
				searchoptions :{
					sopt:['cn','nc']
				}
			}, {
				name : 'sex',
				index : 'sex',
				width : 50,
				editable : true,
				edittype : "select",
				align : "center",
				editoptions : {
					value : '0:男;1:女'
				},
				formatter : function(cellvalue, options, row) {
					if (cellvalue == 0) {
						return "男";
					} else {
						return "女";
					}
				},
				stype:'select',
				searchoptions :{
					sopt:['eq','ne'],
					dataUrl:"<%=request.getContextPath()%>/jsp/sex.jsp"
				}
			}, {
				name : 'address',
				index : 'address',
				align : "center",
				width : 50,
				editable : true,
				editrules:{
					required:true
				},
				searchoptions :{
					sopt:['cn','nc']
				}
			}, {
				name : 'phone',
				index : 'phone',
				align : "center",
				width : 50,
				editable : true,
				editrules:{
					required:true,
					integer:true
				},
				searchoptions :{
					sopt:['cn','nc']
				}
			}, {
				name : 'age',
				index : 'age',
				align : "center",
				width : 50,
				editable : true,
				editrules:{
					required:true,
					integer:true
				},
				searchoptions :{
					sopt:['cn','nc']
				}
			}, {
				name : 'status',
				index : 'status',
				align : "center",
				width : 50,
				editable : true,
				edittype : "select",
				editoptions : {
					value : '0:在职;1:离职'
				},
				formatter : function(cellvalue, options, row) {
					if (cellvalue == 0) {
						return "在职";
					} else {
						return "离职";
					}
				},
				stype:'select',
				searchoptions :{
					sopt:['eq','ne'],
					dataUrl:"<%=request.getContextPath()%>/jsp/status.jsp"
				}
			}, {
				name : 'enterTime',
				index : 'enterTime',
				align : "center",
				width : 50,
				editable : true,
				formatter : "date",
				editrules:{
					required:true,
					date:true
				},
				formatoptions : {
					"newformat" : "Y-m-d"
				},
				editoptions : {
					size : 10,
					maxlengh : 10,
					dataInit : function(element) {
						$(element).datepicker({
							dateFormat : 'yy-mm-dd'
						});
					}
				},
				searchoptions:{dataInit:datePick,sopt:['le','ge']}
			}],
			rowNum : 10,
			rowList : [ 10, 20, 30 ],
			pager : '#employeegridPager',
			sortname : 'id',
			viewrecords : true,
			jsonReader : {
				repeatitems : false
			},
			sortorder : "desc",
			caption : "员工信息",
			editurl : "editEmployee.action",
		});
		jQuery("#employeelist").jqGrid('navGrid', '#employeegridPager', {
			edit : true,
			add : true,
			del : false
		}, {}, {}, {}, {
			multipleSearch : true
		});
	});
	datePick = function(elem)
	{
	   jQuery(elem).datepicker();
	}
</script>
<body>
	<div align="center">
		<table id="employeelist"></table>
		<div id="employeegridPager"></div>
	</div>
</body>
</html>